CC = g++
SRCS = $(wildcard src/*.cpp)
OBJS = $(patsubst src/%.cpp, build/%.o, $(SRCS))
CXXFLAGS = -std=c++11
TARGET = build/xxxfile
TARGET_DEBUG = build/xxxfile-debug

all: release

pre-build:
	mkdir -p build

debug: TARGET = $(TARGET_DEBUG)
debug: CXXFLAGS += -fsanitize=address -fsanitize=leak -fsanitize=bounds-strict -g
debug: LDFLAG += -fsanitize=address -fsanitize=leak -fsanitize=bounds-strict -g
debug: $(TARGET)

release: clean pre-build $(TARGET)


$(TARGET):$(OBJS)
	$(CC) $(LDFLAG) -o $(TARGET) $(OBJS) 

build/%.o:src/%.cpp
	$(CC) -o $@ -c $< $(CXXFLAGS)

install:
	sudo cp $(TARGET) /usr/bin/

uninstall:
	sudo rm /usr/bin/$(TARGET)
	
clean:
	rm -rf $(TARGET) $(OBJS)
